<?php

class DefaultController extends Controller
{
	public function actionIndex()
	{
		$model=new Orders('search');
		$model->unsetAttributes();
		if(isset($_GET['Orders']))
			$model->attributes=$_GET['Orders'];

		$this->render('index', array(
			'model'=>$model
		));
	}
    
    public function actionView($id)
    {
        $model = Orders::model()->findByPk($id);
        
         $this->render('view', array(
            'model'=>$model
        ));
    }

    public function actionUpdate($id){
    	$model = Orders::model()->findByPk($id);
    	if($model->status == "P"){
    		$model->updateByPk($model->id, array('status'=>'D')) ;
    	}else{
    		$model->updateByPk($model->id, array('status'=>'P')) ;
    	}
    	$this->redirect(array('view','id'=>$model->id));
    }
}